home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11450 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.iadfw.net!usenet
  2. From: Larry Weiss <lfw@iadfw.net>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Newbie Questions
  5. Date: Sat, 23 Mar 1996 21:56:42 -0600
  6. Organization: customer of Internet America
  7. Message-ID: <3154C7FA.B38@iadfw.net>
  8. References: <4irpc1$b8u@GRAPEVINE.LCS.MIT.EDU> <4isgta$7cr@newsbf02.news.aol.com> <827628456snz@genesis.demon.co.uk>
  9. NNTP-Posting-Host: dal12-25.ppp.iadfw.net
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.01 (Win16; I)
  14.  
  15. Lawrence Kirby wrote:
  16.  > 
  17.  > In article <4isgta$7cr@newsbf02.news.aol.com>
  18.  >            mvaccaro1@aol.com "MVaccaro1" writes:
  19.  > >try this little test and tell me what happens:
  20.  > >
  21.  > >main( )
  22.  > >   {
  23.  > >   char *s1 = "hello";
  24.  > >   char s2[ ] = "hello";
  25.  > >
  26.  > >   printf( "Sizeof s1 %d\n Sizeof s2 %d\n", sizeof s1, sizeof s2 );
  27.  > 
  28.  > Anything can happen since sizeof doesn't return an int value, it returns
  29.  > a value with some implementation specific unsigned type (size_t). The
  30.  > correct way to write this is:
  31.  > 
  32.  >     printf( "Sizeof s1 %lu\n Sizeof s2 %lu\n", (unsigned long) sizeof s1,
  33.  >                                                (unsigned long) sizeof s2 );
  34.  > >   return 0;
  35.  > >   }
  36.  > 
  37.  
  38. Since printf() is a member of the standard library (with unambiguous semantics)
  39. couldn't the implementation be required to issue a diagnostic if a mismatch
  40. were attempted?   If so, would the Standard need to say so explicitly?
  41.  
  42. The information is clearly available to the implementation to support an
  43. unambiguous diagnostic.
  44.